home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8401.arc
/
BASIC2.BAS
< prev
next >
Wrap
BASIC Source File
|
1983-09-16
|
2KB
|
72 lines
'This program section allows the waveform stored in an array to be plotted on
'an X-Y plotter using the 2 digital-to-analog converters on the Labmaster
'board. The waveforms are stored in the integer array x% which has been
'dimensioned x%(645,29). The array x%(a,b) is used as follows: b (0 thru 29)
'is the run number; for each level of b the actual waveform values are
'stored in a=1 thru a=640.
'
CLS : PRINT "Routine for X-Y recorder plots of waveforms" : PRINT
PRINT "Connect d/a channel 0 to X-input of recorder,"
PRINT "Connect d/a channel 1 to Y-input of recorder." : PRINT
'
'now get run number of desired waveform
'
2350 INPUT "Run number (1-30) to plot";PLOTRUN%
'
'make sure the input value are within range
'
IF PLOTRUN%<1 OR PLOTRUN%>30 THEN PRINT "Out of range" : GOTO 2350
'
'since array is dimensioned 0-29, must subtract 1 from PLOTRUN%
'
PLOTRUN%=PLOTRUN%-1
'
'zero plotter pen by commanding both d/a converters to zero volts
'
OUT &H711,0 : OUT &H710,0 : OUT &H713,0 : OUT &H712,0
'
INPUT "Lower pen, hit return for plot (enter M for menu)";K$
IF K$="M" OR K$="m" THEN GOTO 290
'
'calculate and send values to d/a converters
'
'p%(7) is a parameter set in another part of the program - it determines how
'much of the waveform is plotted. Its value is always 640, 320, or 160.
'
DL%=640/P%(7)
'
'loop once for each data point
'
FOR I%=1 TO p%(7)
'
'the d/a converters are 12 bit, but we can send only 8 at a time; the value
'to be sent must be divided into a low byte and a high byte (the left 4 bits
'of the high byte are ignored).
'
'calculate the x-coordinate
'
HIGH0%=INT(I%*3*DL%/256)
LOW0%=I%*3*DL%-256*HIGH0%
'
'calculate the y coordinate
'
HIGH1%=INT(X%(I%,PLOTRUN%)/256)
LOW1%=X%(I%,PLOTRUN%)-HIGH1%*256
IF HIGH1%<0 THEN HIGH1%=16+HIGH1%
'
'send the x value to d/a 0, the y value to d/a 1
'
OUT &H711,HIGH0% : OUT &H710,LOW0%
OUT &H713,HIGH1% : OUT &H712,LOW1%
'
'now a delay loop because the computer is faster than the plotter
'
FOR K=1 TO 20 : NEXT K
'
NEXT I%
'
'done, so beep and return
'
BEEP : return
'